import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const routes = [
  // 首页
  {
    path: "/home",
    name: "home",
    component: HomeView,
  },
  {
    path: "/", // 重定向到首页  path:'/', 不用换  只改变redirect:'/xxx'
    redirect: "/home",
  },
  // 教程
  {
    path: "/course",
    name: "CourseView",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/CourseView.vue"),
  },
  // 网校
  {
    path: "/school",
    name: "SchoolView",
    component: () => import("../views/SchoolView.vue"),
  },
  // 大触
  {
    path: "/dachu",
    name: "DachuView",
    component: () => import("../views/DachuView.vue"),
    // 大触的二级路由导航 大触直播 大触专访 大触周边
    children: [
      {
        path: "dcLive",
        // path: "", // 二级路由的大触直播设为空 原因是：当点一级路由的大触时，默认显示大触直播的页面
        name: "DachuTwoLive",
        component: () => import("../views/DachuTwoLive.vue"),
      },
      {
        path: "dcVisit",
        name: "DachuTwoVisit",
        component: () => import("../views/DachuTwoVisit.vue"),
      },
      {
        path: "dcAround",
        name: "DachuTwoAround",
        component: () => import("../views/DachuTwoAround.vue"),
      },
      // 二级路由默认显示的页面用重定向
      // {
      //   path: "/dachu",
      //   redirect: (to) => {
      //     return {
      //       name: "DachuTwoLive",
      //     };
      //   },
      // },
    ],
    redirect: "/dachu/dcLive", // 二级路由默认显示的页面用重定向
  },
  // 详情页 大触-->大触直播-->即将直播
  {
    path: "/dcLiveDetails",
    name: "DachuLiveDetails",
    component: () => import("../views/DachuLiveDetails.vue"),
  },
  // 详情页 大触-->大触直播-->往期直播
  {
    path: "/dcLiveDetailsAgo",
    name: "DachuLiveDetailsAgo",
    component: () => import("../views/DachuLiveDetailsAgo.vue"),
  },
  // 大触-->大触专访的详情页
  {
    path: "/DachuTwoLiveInfo",
    name: "LiveInfo",
    component: () => import("../views/DachuTwoLiveInfo.vue"),
  },

  // 社区
  {
    path: "/community",
    name: "CommunityView",
    component: () => import("../views/CommunityView.vue"),
    // 社区的二级路由导航 作业 问答 动态 指绘
    children: [
      {
        path: "/cTwoTask",
        name: "CommunityTwoTask",
        component: () => import("../views/CommunityTwoTask.vue"),
      },
      {
        path: "/cTwoAnswers",
        name: "CommunityTwoAnswers",
        component: () => import("../views/CommunityTwoAnswers.vue"),
      },
      {
        path: "/cTwoDynamic",
        name: "CommunityTwoDynamic",
        component: () => import("../views/CommunityTwoDynamic.vue"),
      },
      {
        path: "/cTwoDraw",
        name: "CommunityTwoDraw",
        component: () => import("../views/CommunityTwoDraw.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
